package com.LeetCode.Array;

import org.junit.Test;

/**
 * 移动零
 */
public class MoveZero {
    public void moveZeroes(int[] nums){
        int curIndex = 0;
        for(int num : nums){
            if(num!=0)
                nums[curIndex++] = num;
        }

        while(curIndex < nums.length){
            nums[curIndex++] = 0;
        }
    }

    @Test
    public void test(){
        int[] nums = {0,1,0,3,12};
        moveZeroes(nums);
        for(int num : nums){
            System.out.println(num);
        }
    }
}
